const express = require("express")
const formidableMiddleware = require("express-formidable")
const cors = require("cors")
const app = express()
app.use(cors())
app.use(
    formidableMiddleware({
      uploadDir: './my/dir', //配置上传到服务器的文件存储的路径
      keepExtensions: true, // 上传的文件存储时保持后缀名
    })
  )
app.use(formidableMiddleware())
app.use(express.urlencoded({extended:false}))
app.get("/test",(req,res)=>{
    const {callback} = req.query
    res.send(`${callback}("哈哈哈")`)
})
app.post("/test",(req,res)=>{
    // res.send(req.fields)
    // res.send(req.files)
    res.send([req.fields,req.files])
})
app.listen(5000,(err)=>{
    if(!err) console.log("成功")
    else console.log("失败")
})